//
//  MessageRemindViewController.m
//  SouthChina
//
//  Created by Mr.Y on 14-10-9.
//  Copyright (c) 2014年 科创. All rights reserved.
//

#import "MessageRemindViewController.h"
@interface MessageRemindViewController ()
@property(strong, nonatomic) UISwitch *voiceRemindSwitchBtn;
@property(strong, nonatomic) UISwitch *vibrationRemindSwitchBtn;
@property(strong, nonatomic) UISwitch *pictureRemindSwitchBtn;


@end

@implementation MessageRemindViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
       

    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self addTitleBarWithBackBtn:@"消息提醒" needReturn:YES];
    self.view.backgroundColor = [UIColor colorWithRed:236/255.0f green:235/255.0f blue:243/255.0f alpha:1];;
    UIView * voiceBackView = [[UIView alloc] initWithFrame:CGRectMake(10, (YNEW)+TITLE_BAR_HEGIHT+20, SCREEN_WIDTH-20, 40)];
    voiceBackView.layer.masksToBounds = YES;
    voiceBackView.layer.cornerRadius = 5.0;
    voiceBackView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:voiceBackView];
    UILabel * voiceLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 9, 120, 21)];
    voiceLabel.text = @"声音提醒";
    [voiceBackView addSubview:voiceLabel];
    _voiceRemindSwitchBtn = [[UISwitch alloc] initWithFrame:CGRectMake((SCREEN_WIDTH)-100+(YNEW), 5, 20, 20)];
    [_voiceRemindSwitchBtn addTarget:self action:@selector(switchBtn:) forControlEvents:UIControlEventValueChanged];
    [voiceBackView addSubview:_voiceRemindSwitchBtn];

    UIView * vibrationBackView = [[UIView alloc] initWithFrame:CGRectMake(10, voiceBackView.frame.size.height+voiceBackView.frame.origin.y+10, SCREEN_WIDTH-20, 40)];
    vibrationBackView.layer.masksToBounds = YES;
    vibrationBackView.layer.cornerRadius = 5.0;
    vibrationBackView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:vibrationBackView];
    UILabel * allowStudentLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 9, 120, 21)];
    allowStudentLabel.text = @"震动提醒";
    [vibrationBackView addSubview:allowStudentLabel];
    _vibrationRemindSwitchBtn = [[UISwitch alloc] initWithFrame:CGRectMake((SCREEN_WIDTH)-100+(YNEW), 5, 20, 20)];
    [_vibrationRemindSwitchBtn addTarget:self action:@selector(switchBtn:) forControlEvents:UIControlEventValueChanged];
    [vibrationBackView addSubview:_vibrationRemindSwitchBtn];

    UIView * pictureSetBackView = [[UIView alloc] initWithFrame:CGRectMake(10, vibrationBackView.frame.size.height+vibrationBackView.frame.origin.y+10, SCREEN_WIDTH-20, 40)];
    pictureSetBackView.layer.masksToBounds = YES;
    pictureSetBackView.layer.cornerRadius = 5.0;
    pictureSetBackView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:pictureSetBackView];
    UILabel * pictureLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 9, 200, 21)];
    pictureLabel.text = @"WIFI连接下才下载图片";
    [pictureSetBackView addSubview:pictureLabel];
    _pictureRemindSwitchBtn = [[UISwitch alloc] initWithFrame:CGRectMake((SCREEN_WIDTH)-100+(YNEW), 5, 20, 20)];
    [_pictureRemindSwitchBtn addTarget:self action:@selector(switchBtn:) forControlEvents:UIControlEventValueChanged];
    [pictureSetBackView addSubview:_pictureRemindSwitchBtn];

    if ([@"OFF" isEqualToString:[DE getGlobalVar:ISSOUND]]) {
        [_voiceRemindSwitchBtn setOn:NO];
    }else
    {
        [_voiceRemindSwitchBtn setOn:YES];

    }
    if ([@"OFF" isEqualToString:[DE getGlobalVar:ISVIBRATE]]) {
        [_vibrationRemindSwitchBtn setOn:NO];
    }else
    {
        [_vibrationRemindSwitchBtn setOn:YES];
        
    }
    if ([@"ON" isEqualToString:[DE getGlobalVar:ISWIFILOADPIC]]) {
        [_pictureRemindSwitchBtn setOn:YES];
    }else
    {
        [_pictureRemindSwitchBtn setOn:NO];
        
    }
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (void)switchBtn:(id)sender {
    if ([_voiceRemindSwitchBtn isOn]) {
        [DE setGlobalVar:ISSOUND value:@"ON"];
    }else
    {
        [DE setGlobalVar:ISSOUND value:@"OFF"];

    }
    if ([_vibrationRemindSwitchBtn isOn]) {
        [DE setGlobalVar:ISVIBRATE value:@"ON"];
    }else
    {
        [DE setGlobalVar:ISVIBRATE value:@"OFF"];
        
    }if ([_pictureRemindSwitchBtn isOn]) {
        [DE setGlobalVar:ISWIFILOADPIC value:@"ON"];
    }else
    {
        [DE setGlobalVar:ISWIFILOADPIC value:@"OFF"];
        
    }
    
    NSLog(@"提交时震动提醒：%@",[DE getGlobalVar:ISVIBRATE]);
}


@end
